package com.example.javapoint.threads.priority;

public class ThreadPriorityExample extends Thread{
    @Override
    public void run() {
        System.out.println("子线程内部的run() 方法执行了...");
    }

    public static void main(String[] args) {
        ThreadPriorityExample t1 = new ThreadPriorityExample();
        ThreadPriorityExample t2 = new ThreadPriorityExample();
        ThreadPriorityExample t3 = new ThreadPriorityExample();

        System.out.println("t1 的优先级是----->" + t1.getPriority());
        System.out.println("t2 的优先级是----->" + t2.getPriority());
        System.out.println("t3 的优先级是----->" + t3.getPriority());

        t1.setPriority(3);
        t2.setPriority(6);
        t3.setPriority(9);
        System.out.println("第一次修改完之后，t1 的优先级是----->" + t1.getPriority());
        System.out.println("第一次修改完之后，t2 的优先级是----->" + t2.getPriority());
        System.out.println("第一次修改完之后，t3 的优先级是----->" + t3.getPriority());

        System.out.println("当前在运行的线程----->" + Thread.currentThread().getName());
        System.out.println("当前在运行的线程的优先级----->" + Thread.currentThread().getPriority());

        Thread.currentThread().setPriority(10);
        System.out.println("修改之后，当前在运行的线程的优先级----->" + Thread.currentThread().getPriority());
    }
}
